/***************************************************************************
 *   Copyright (C) 2009 by betox2099   *
 *   betox2099@yahoo.com.mx   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "PuzzleView.h"

PuzzleView::PuzzleView(Puzzle &p_puzzle)
{
	puzzle = &p_puzzle;
}

PuzzleView::~PuzzleView(){}

void PuzzleView::setPuzzle(Puzzle &p_puzzle)
{
	puzzle = &p_puzzle;
}

void PuzzleView::draw(CL_GraphicContext &p_gc)
{
	int size_block = 10;
	int offset_x = 10;
	int offset_y = 10;
	std::vector<Block *> blocks;
	std::vector<Block *>::iterator iterador;
	Block *point;

	blocks = puzzle->getBlocks();
	iterador = blocks.begin();

	while(iterador != blocks.end()){
		point = (Block *)*iterador;
		CL_Draw::fill(p_gc,(point->getPosition()->x*size_block)+offset_x,
                                   (point->getPosition()->y*size_block)+offset_y,
                                   (point->getPosition()->x*size_block)+offset_x+size_block,
 				   (point->getPosition()->y*size_block)+offset_y+size_block,
                                  CL_Colorf::red);
		++iterador;	
	}
}
